<?php
/**
 * User: hufeng
 * Date: 2017/7/11
 * Desc: 重启swoole服务
 * php restart.php jsserve reload
 */
if(@!$argv[0] && @!$argv[1] && @!$argv[2]){
    echo 'need param';exit;
}
if(@$argv[2]=='stop'){
    $pid = system('pidof '.$argv[1]);
    system('kill -15 '.$pid);
    echo $argv[1]." stop done\n";exit;
}elseif(@$argv[2]=='reload'){
    $pid = system('pidof '.$argv[1]);
    system('kill -USR1 '.$pid);
    echo $argv[1]." reload done\n";exit;
}elseif(@$argv[2]=='restart'){
    $pid = system('pidof '.$argv[1]);
    system('kill -15 '.$pid,$retval);
    sleep(1);
    system('php '.$argv[1].'.php');
    echo $argv[1]." restart done\n";exit;
}